﻿// --------------------------------------------------------------------------------------------------------------------
// <copyright file="VolumeNotificationHandler.cs" company="Matthias Friedrich">
//   Copyright © Matthias Friedrich 2009
// </copyright>
// --------------------------------------------------------------------------------------------------------------------

namespace DeviceManagement
{
	using System;

	public class VolumeNotificationHandler : DeviceNotificationHandler
	{
		public VolumeNotificationHandler()
			: base()
		{
		}

		protected override void OnDeviceArrival(DeviceNotificationEventArgs e)
		{
			base.OnDeviceArrival(e);

			if (e.IsVolume())
			{
				this.OnVolumeArrival(e);
			}
		}

		protected override void OnDeviceRemoveComplete(DeviceNotificationEventArgs e)
		{
			base.OnDeviceRemoveComplete(e);

			if (e.IsVolume())
			{
				this.OnVolumeRemoveComplete(e);
			}
		}

		#region VolumeArrival

		private static readonly object VolumeArrivalEvent = new object();

		protected virtual void OnVolumeArrival(DeviceNotificationEventArgs e)
		{
			this.InvokeEvent(VolumeArrivalEvent, e);
		}

		public event EventHandler<DeviceNotificationEventArgs> VolumeArrival
		{
			add
			{
				this.Events.AddHandler(VolumeArrivalEvent, value);
			}

			remove
			{
				this.Events.RemoveHandler(VolumeArrivalEvent, value);
			}
		}

		#endregion

		#region VolumeRemoveComplete

		private static readonly object VolumeRemoveCompleteEvent = new object();

		protected virtual void OnVolumeRemoveComplete(DeviceNotificationEventArgs e)
		{
			this.InvokeEvent(VolumeRemoveCompleteEvent, e);
		}

		public event EventHandler<DeviceNotificationEventArgs> VolumeRemoveComplete
		{
			add
			{
				this.Events.AddHandler(VolumeRemoveCompleteEvent, value);
			}

			remove
			{
				this.Events.RemoveHandler(VolumeRemoveCompleteEvent, value);
			}
		}

		#endregion
	}
}